package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.UserSignIn;
import com.ruoyi.system.service.IUserSignInService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户签到信息Controller
 *
 * @author ruoyi
 * @date 2025-01-17
 */
@RestController
@RequestMapping("/system/signIn")
public class UserSignInController extends BaseController
{
    @Autowired
    private IUserSignInService userSignInService;

    /**
     * 查询用户签到信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:signIn:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserSignIn userSignIn)
    {
        startPage();
        List<UserSignIn> list = userSignInService.selectUserSignInList(userSignIn);
        return getDataTable(list);
    }

    /**
     * 导出用户签到信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:signIn:export')")
    @Log(title = "用户签到信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserSignIn userSignIn)
    {
        List<UserSignIn> list = userSignInService.selectUserSignInList(userSignIn);
        ExcelUtil<UserSignIn> util = new ExcelUtil<UserSignIn>(UserSignIn.class);
        util.exportExcel(response, list, "用户签到信息数据");
    }

    /**
     * 获取用户签到信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:signIn:query')")
    @GetMapping(value = "/{userSignInId}")
    public AjaxResult getInfo(@PathVariable("userSignInId") Long userSignInId)
    {
        return success(userSignInService.selectUserSignInByUserSignInId(userSignInId));
    }

    /**
     * 新增用户签到信息
     */
    @PreAuthorize("@ss.hasPermi('system:signIn:add')")
    @Log(title = "用户签到信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserSignIn userSignIn)
    {
        return toAjax(userSignInService.insertUserSignIn(userSignIn));
    }

    /**
     * 修改用户签到信息
     */
    @PreAuthorize("@ss.hasPermi('system:signIn:edit')")
    @Log(title = "用户签到信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserSignIn userSignIn)
    {
        return toAjax(userSignInService.updateUserSignIn(userSignIn));
    }

    /**
     * 删除用户签到信息
     */
    @PreAuthorize("@ss.hasPermi('system:signIn:remove')")
    @Log(title = "用户签到信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{userSignInIds}")
    public AjaxResult remove(@PathVariable Long[] userSignInIds)
    {
        return toAjax(userSignInService.deleteUserSignInByUserSignInIds(userSignInIds));
    }
}
